namespace TXLooker.WorkItemExtention.WIQL
{
    using System;
    using System.Globalization;

    public static class ConditionalOperators
    {
        private static string[] s_Strings = new string[] { "=", "<>", "<", ">", "<=", ">=", "under", "in", "contains", "==", "!=" };

        public static Condition Find(string s)
        {
            s = s.ToLower(CultureInfo.InvariantCulture);
            Condition condition = (Condition) (Array.IndexOf<string>(s_Strings, s) + 1);
            switch (condition)
            {
                case Condition.EqualsAlias:
                    return Condition.Equals;

                case Condition.NotEqualsAlias:
                    return Condition.NotEquals;
            }
            return condition;
        }

        public static string GetString(Condition c)
        {
            return s_Strings[((int) c) - 1];
        }

        public static bool IsValid(string s)
        {
            return (Find(s) != Condition.None);
        }
    }
}

